import { Scene, PerspectiveCamera, WebGLRenderer } from "three";
export class BasicUniverse {
  scene;
  camera;
  container;
  renderer;

  /**
   * 构造函数
   * @param {string} id - 挂载节点id
   */
  constructor(id) {
    this.container = document.getElementById(id);
    this.scene = new Scene;
    const aspect = this.container.clientWidth / this.container.clientHeight;
    this.camera = new PerspectiveCamera(35, aspect, 0.1, 100);
    this.camera.position.set(0, 0, 10);
    this.renderer = new WebGLRenderer();
    this.renderer.setSize(
      this.container.clientWidth,
      this.container.clientHeight
    );
    this.renderer.setPixelRatio(window.devicePixelRatio);
    this.container.append(this.renderer.domElement);
  }

  render() {
    this.renderer.render(this.scene, this.camera);
  }
}
